<script src = "https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.min.js"> </script>
<script>

    const params = new URLSearchParams(window.location.search);
    // 获取AppId
    const appid = params.get("appId");
    // 回调地址
    const redirectUrl = params.get("redirectUrl");
    // 重定向后原样带回，可以为空
    const state = params.get("state");
    ap.getAuthCode ({
        appId :  appid ,
        scopes : ['auth_base'],
    },function(res){
        const authCode = res.authCode;
        // 跳转到回调地址
        window.location.replace(`${redirectUrl}?state=${state}&code=${authCode}`)
        // window.location.href = `${redirectUrl}?code=${authCode}`;

    });
</script>
